package com.corechina.apex_osswords.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.corechina.apex_osswords.common.Response;
import com.corechina.apex_osswords.common.ShiroUtils;
import com.corechina.apex_osswords.domain.dao.CorePlaceMapper;
import com.corechina.apex_osswords.domain.entity.CorePlace;
import com.corechina.apex_osswords.domain.vo.CorePlaceVo;
import com.corechina.apex_osswords.service.ICorePlaceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 地点管理 服务实现类
 * </p>
 *
 * @author cc
 * @since 2022-05-30
 */
@Service
public class CorePlaceServiceImpl extends ServiceImpl<CorePlaceMapper, CorePlace> implements ICorePlaceService {

    @Autowired
    private CorePlaceMapper corePlaceMapper;

    @Override
    public int updateIsDel(Integer isDel, Integer id) {
        return corePlaceMapper.updateIsDel(isDel, id);
    }

    @Override
    public Response getList(String name, Integer serviceId, Integer enterpriseId, Integer pageIndex, Integer pageSize) {
        IPage<CorePlaceVo> placeIPage = corePlaceMapper.getList(new Page(pageIndex, pageSize), name, serviceId, enterpriseId);
        return Response.ok(placeIPage.getRecords(), placeIPage.getTotal());
    }


    @Override
    public Response getPlaceList(Integer isDel, Integer projectId, Integer pageIndex, Integer pageSize) {
        IPage<CorePlaceVo> projectVoIPage = corePlaceMapper.getPlaceList(new Page(pageIndex, pageSize), isDel, projectId);
        return Response.ok(projectVoIPage.getRecords(), projectVoIPage.getTotal());
    }
}
